<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
      $(function() {
        $("#validForm").validate({
          submitHandler: function(form) {
            $("#validForm input[name|='dy']").each(function() {
              var name = $(this).attr("name");
              $(this).attr("name",name.substring(3,name.lastIndexOf("-")));
            });
            form.submit();
          }
        });
        $("input[name='name']").focus();
      });
      function confirmDelete() {
        return confirm("<s:message code='confirmDelete'/>");
      }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>直播 - <s:message code="${oprt=='edit' ? 'edit' : 'create'}"/></h1>
</div>
<c:set var="numberExist"><s:message code="vote.number.exist"/></c:set>
<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="${oprt=='edit' ? 'update' : 'save'}.do" method="post">
            <tags:search_params/>
            <f:hidden name="id" value="${bean.id}"/>
            <f:hidden name="position" value="${position}"/>
            <input type="hidden" id="redirect" name="redirect" value="edit"/>
            <div class="box-header with-border">
                <div class="btn-toolbar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:vote:create">
                            <button class="btn btn-default" type="button" onclick="location.href='create.do?${searchstring}';"<c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <%--<shiro:hasPermission name="ext:vote:copy">--%>
                        <%--<button class="btn btn-default" type="button" onclick="location.href='create.do?id=${bean.id}&${searchstring}';"<c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message code="copy"/></button>--%>
                        <%--</shiro:hasPermission>--%>
                        <shiro:hasPermission name="ext:vote:delete">
                            <button class="btn btn-default" type="button" onclick="if(confirmDelete()){location.href='delete.do?ids=${bean.id}&${searchstring}stat=${stat}';}"<c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message code="delete"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <button class="btn btn-default" type="button" onclick="location.href='edit.do?id=${side.prev.id}&position=${position-1}&${searchstring}stat=${stat}';"<c:if test="${empty side.prev}"> disabled="disabled"</c:if>><s:message code="prev"/></button>
                        <button class="btn btn-default" type="button" onclick="location.href='edit.do?id=${side.next.id}&position=${position+1}&${searchstring}stat=${stat}';"<c:if test="${empty side.next}"> disabled="disabled"</c:if>><s:message code="next"/></button>
                    </div>
                    <div class="btn-group">
                        <button class="btn btn-default" type="button" onclick="location.href='list.do?${searchstring}stat=${stat}';"><s:message code="return"/></button>
                    </div>
                </div>
            </div>
            <div class="box-body">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em>直播标题</label>
                            <div class="col-sm-10">
                                <f:text name="title" value="${oprt=='edit' ? (bean.title) : ''}" class="form-control required" maxlength="150"/>
                            </div>
                        </div>
                    </div>
                </div>
                <%--<div class="row">--%>
                <%--<div class="col-sm-12">--%>
                <%--<div class="form-group">--%>
                <%--<label class="col-sm-2 control-label"><s:message code="vote.number"/></label>--%>
                <%--<div class="col-sm-10">--%>
                <%--<f:text name="number" value="${bean.number}" class="form-control {remote:'check_number.do?original=${bean.number}',messages:{remote:'${numberExist}'}}" maxlength="100"/>--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--</div>--%>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">直播简介</label>
                            <div class="col-sm-10">
                                <f:textarea name="introduction" value="${bean.introduction}" class="form-control {maxlength:255}" rows="5"/>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><em class="required">*</em><s:message code="vote.status"/></label>
                        <div class="col-sm-8">
                            <select class="form-control" name="status" id="select_1">
                                <f:option value="0" selected="${bean.status}" default="0"><s:message code="live.0"/></f:option>
                                <f:option value="1" selected="${bean.status}"><s:message code="live.1"/></f:option>
                                <f:option value="2" selected="${bean.status}"><s:message code="live.2"/></f:option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">开播时间</label>
                            <div class="col-sm-8">
                                <input class="form-control" type="text" name="time" value="${bean.time}" onclick="WdatePicker({dateFmt:'yyyy-MM-ddTHH:mm:ss'});"/>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">直播封面</label>
                                <div class="col-sm-10">
                                    <script>
                                      function fn_smallImage(src) {
                                        Cms.scaleImg("img_smallImage",200,100,src);
                                      };
                                    </script>
                                    <div style="display:table;width:100%;">
                                        <div style="display:table-cell;vertical-align:middle;">
                                            <div class="input-group">
                                                <span class="input-group-addon">地址</span>
                                                <input type="text" id="smallImage" name="image" value="${bean.image}" onchange="fn_smallImage(this.value);" class="form-control ">
                                            </div>
                                            <div class="form-inline" style="margin-top:3px;">
                                                <div class="input-group">
                                                    <span class="input-group-addon">宽</span>
                                                    <input type="text" id="w_smallImage" value="180" style="width:70px;" class="form-control">
                                                </div>
                                                <div class="input-group">
                                                    <span class="input-group-addon">高</span>
                                                    <input type="text" id="h_smallImage" value="120" style="width:70px;" class="form-control">
                                                </div>
                                                <button class="btn btn-default" type="button" id="smallImageButton">选择</button>
                                                <button class="btn btn-default" type="button" onclick="imgCrop('smallImage');">裁剪</button>
                                                <object id="SWFUpload_0" type="application/x-shockwave-flash" data="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304" width="54" height="34" class="swfupload"><param name="wmode" value="transparent"><param name="movie" value="/static/vendor/swfupload/swfupload.swf?preventswfcaching=1502702265304"><param name="quality" value="high"><param name="allowScriptAccess" value="always"><param name="flashvars" value="movieName=SWFUpload_0&amp;uploadURL=%2Fcmscp%2Fcore%2Fupload_image.do%3Bjsessionid%3DB7EED2164EABD024D9BFE3361803971D%3F_site%3D&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=&amp;filePostName=file&amp;fileTypes=*.*&amp;fileTypesDescription=Images&amp;fileSizeLimit=0&amp;fileUploadLimit=0&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=&amp;buttonWidth=54&amp;buttonHeight=34&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-100&amp;buttonDisabled=false&amp;buttonCursor=-2"></object>
                                                <button class="btn btn-default" type="button">上传</button>
                                                <button class="btn btn-default" type="button" id="smallImageSwfCancel" onclick="smallImageSwfUpload.cancelQueue();" disabled="">取消</button>
                                            </div>
                                            <div>
                                                <label class="checkbox-inline"><input type="checkbox" id="s_smallImage" checked="checked">压缩</label>
                                                <label class="checkbox-inline"><input type="checkbox" id="e_smallImage">不按原图比例</label>
                                                <label class="checkbox-inline"><input type="checkbox" id="wm_smallImage">水印</label>
                                            </div>
                                            <input type="hidden" id="t_smallImage" value="false">
                                            <input type="hidden" id="tw_smallImage" value="116">
                                            <input type="hidden" id="th_smallImage" value="77">
                                        </div>
                                        <div style="width:200px;display:table-cell;vertical-align:middle;text-align:center;">
                                            <img id="img_smallImage" style="display:none;">
                                        </div>
                                    </div>
                                    <div id="smallImageSwfProgress"></div>
                                    <script>
                                      var smallImageSwfUpload = Cms.swfUploadImage("smallImage",{
                                        jsessionid: "B7EED2164EABD024D9BFE3361803971D",
                                        file_size_limit: "0",
                                        file_types: "*.*"
                                      });
                                      $(function() {
                                        Cms.f7.uploads("smallImage","smallImage",{
                                          settings: {"title": "选择附件"},
                                          callbacks: {"ok": function(src){
                                            fn_smallImage(src);
                                          }}
                                        });
                                      });
                                      fn_smallImage("");
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><em class="required"></em>开关预约</label>
                            <div class="col-sm-8">
                                <label class="radio-inline"><f:radio name="maxSelected" value="0" checked="${bean.subscribe}" default="0"/>关闭预约</label>
                                <label class="radio-inline"><f:radio name="maxSelected" value="1" checked="${bean.subscribe}"/>开启预约</label>
                            </div>
                        </div>
                    </div>
                    <%--<div class="col-sm-6">--%>
                        <%--<div class="form-group">--%>
                            <%--<label class="col-sm-4 control-label"><s:message code="vote.endDate"/></label>--%>
                            <%--<div class="col-sm-8">--%>
                                <%--<input class="form-control" type="text" name="endDate" value="<fmt:formatDate value="${bean.endDate}" pattern="yyyy-MM-dd'T'HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-ddTHH:mm:ss'});"/>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                    <%--</div>--%>
                </div>
                <%--<div class="row">--%>
                <%--<div class="col-sm-6">--%>
                <%--<div class="form-group">--%>
                <%--<label class="col-sm-4 control-label"><em class="required">*1</em><s:message code="vote.mode"/></label>--%>
                <%--<div class="col-sm-8">--%>
                <%--<select class="form-control" name="mode">--%>
                <%--<f:option value="0" selected="${bean.mode}" default="1"><s:message code="vote.mode.0"/></f:option>--%>
                <%--<f:option value="1" selected="${bean.mode}" default="1"><s:message code="vote.mode.1"/></f:option>--%>
                <%--<f:option value="2" selected="${bean.mode}" default="1"><s:message code="vote.mode.2"/></f:option>--%>
                <%--<f:option value="3" selected="${bean.mode}" default="1"><s:message code="vote.mode.3"/></f:option>--%>
                <%--</select>--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--<div class="col-sm-6">--%>
                <%--<div class="form-group">--%>
                <%--<label class="col-sm-4 control-label"><em class="required">*2</em><s:message code="vote.interval"/><span class="in-prompt" title="<s:message code='vote.interval.prompt'/>"></span></label>--%>
                <%--<div class="col-sm-8">--%>
                <%--<f:text name="interval" value="${bean.interval}" default="0" class="form-control {required:true,digits:true,min:0}" maxlength="9"/>--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--</div>--%>
                <%--</div>--%>
                    <%--<div class="col-sm-6">--%>
                    <%--<div class="form-group">--%>
                    <%--<label class="col-sm-4 control-label"><em class="required">*</em><s:message code="vote.seq"/></label>--%>
                    <%--<div class="col-sm-8">--%>
                    <%--<f:text name="seq" value="${bean.seq}" default="999" class="form-control {required:true,digits:true}" maxlength="9"/>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--</div>--%>
                    <%--<div class="col-sm-6">--%>
                        <%--<div class="form-group">--%>
                            <%--<label class="col-sm-4 control-label"><em class="required">*</em><s:message code="vote.form"/></label>--%>
                            <%--<div class="col-sm-8">--%>
                                <%--<label class="radio-inline"><f:radio name="type" value="0" checked="${bean.type}" default="0"/><s:message code="autonym.0"/></label>--%>
                                <%--<label class="radio-inline"><f:radio name="type" value="1" checked="${bean.type}"/><s:message code="autonym.1"/></label>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                    <%--</div>--%>
                <%--<div class="row">--%>
                    <%--<div class="col-sm-6">--%>
                        <%--<div class="form-group">--%>
                            <%--<label class="col-sm-4 control-label"><s:message code="vote.total"/></label>--%>
                            <%--<div class="col-sm-8">--%>
                                <%--<f:text class="form-control" name="total" value="${bean.total}" default="0" readonly="readonly"/>--%>
                            <%--</div>--%>
                        <%--</div>--%>
                    <%--</div>--%>
                <%--</div>--%>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required"></em>主持人</label>
                            <div class="col-sm-10">
                                <f:text name="compere" value="${(bean.compere)}" class="form-control" maxlength="150"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required"></em>推流地址</label>
                            <div class="col-sm-10">
                                <f:text name="taddress" value="${bean.taddress}" class="form-control" maxlength="150"/>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="inls-opt">
                    <a href="javascript:void(0);" onclick="addRow();" class="ls-opt"><s:message code='addRow'/></a> &nbsp;
                    <a href="javascript:void(0);" onclick="Cms.moveTop('itemIds');" class="ls-opt"><s:message code='moveTop'/></a>
                    <a href="javascript:void(0);" onclick="Cms.moveUp('itemIds');" class="ls-opt"><s:message code='moveUp'/></a>
                    <a href="javascript:void(0);" onclick="Cms.moveDown('itemIds');" class="ls-opt"><s:message code='moveDown'/></a>
                    <a href="javascript:void(0);" onclick="Cms.moveBottom('itemIds');" class="ls-opt"><s:message code='moveBottom'/></a>
                </div>
                <textarea id="templateArea" style="display:none">
					<tr>
                        <td align="center">
                            <input type="checkbox" name="itemIds" value=""/>
                            <input type="hidden" name="dy-itemId-${0}" value=""/>
                        </td>
                        <td align="center">
                          <a href="javascript:void(0);" onclick="$(this).parent().parent().remove();" class="ls-opt">删除</a>
                          <%--<a class="ls-opt" data-toggle="modal" data-target="#myModal">选择</a>--%>
                        </td>
                        <td>
                            <select class="form-control">
                                <option value="0">王</option>
                                <option value="1">李</option>
                                <option value="2">张</option>
                            </select>
                        </td>
                        <td align="center"><f:text name="dy-itemTitle-{0}" value="http://192.168.32.201:1935/live/creedence1111.stream" class="form-control" maxlength="120"/></td>
                        <td align="center"><f:text name="dy-itemTitle-{0}" value="http://192.168.32.201:1935/live/creedence1111.stream/playlist.m3u8" class="form-control" maxlength="120"/></td>
				    <%--<td align="center"><f:text name="dy-itemCount-{0}" value="0" class="form-control {required:true,digits:true,min:0,max:2147483647}" maxlength="10" style="width:100px;text-align:right;"/></td>--%>
				  </tr>
				</textarea>
                <script type="text/javascript">
                    $(function () {
                      $("#select_1").on({
                        change : function (e) {
                          console.log();
                         // location.href=$(this).val();
                         var ri =  $(this).val();
                         if (ri==0){
                           var temp = "/cmscp/ext/livebroadcast/create.do?per=0"
                         }else if (ri==1){
                           var temp = "/cmscp/ext/livebroadcast/create.do?per=1"
                         }else if (ri==2){
                          var temp = "/cmscp/ext/livebroadcast/create.do?per=2"
                        }
                          location.href=temp;
                        }
                      })
                    })
                  var rowIndex = 0;
                  <c:if test="${!empty bean && fn:length(bean.importaddress) gt 0}">
                  rowIndex = ${fn:length(bean.importaddress)};
                  </c:if>
                  var rowTemplate = $.format($("#templateArea").val());
                  function addRow() {
                    $(rowTemplate(rowIndex++)).appendTo("#pagedTable tbody");
                  }
                  $(function() {
                    if(rowIndex==0) {
                      <c:if test="${oprt=='create'}">
                      addRow();
                      </c:if>
                    }
                  });
                </script>
                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead>
                    <tr>
                        <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="80"><s:message code="operate"/></th>
                        <th>名称</th>
                        <th>输入地址</th>
                        <th>输出地址</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="item" varStatus="status" items="${bean.importaddress}">
                        <tr>
                            <td align="center">
                                <input type="checkbox" name="itemIds" value="${bean.id}"/>
                                <%--<input type="hidden" name="dy-itemId-${status.index}" value="${item.id}"/>--%>
                            </td>
                            <td align="center">
                                <!--<a href="javascript:void(0);" onclick="$(this).parent().parent().remove();" class="ls-opt"><s:message code="delete"/></a>-->
                            </td>
                            <%--<td align="center"><f:text name="dy-itemTitle-${status.index}" value="${item.title}" class="form-control required" maxlength="150"/></td>--%>
                            <%--<td align="center"><f:text name="dy-itemCount-${status.index}" value="${item.count}" class="form-control {required:true,digits:true,min:0,max:2147483647}" maxlength="10" style="width:100px;text-align:right;"/></td>--%>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer">
                <button class="btn btn-primary" type="submit"><s:message code="save"/></button>
                <button class="btn btn-default" type="submit" onclick="$('#redirectvote').val('list');"><s:message code="saveAndReturn"/></button>
                <c:if test="${oprt=='create'}">
                    <button class="btn btn-default" type="submit" onclick="$('#redirect').val('create');"><s:message code="saveAndCreate"/></button>
                </c:if>
            </div>
        </form>
    </div>
</div>
</body>
</html>